package com.hdw.web.base.filter;

import com.hdw.common.core.vo.LoginUserVo;
import com.hdw.web.base.shiro.ShiroUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * @Author: ltx
 * @Date: 2021/5/18 16:41
 * @Description:
 */
@Activate(group = "CONSUMER")
@Slf4j
public class DubboContextFilter implements Filter {
    /**
     * Make sure call invoker.invoke() in your implementation.
     *
     * @param invoker
     * @param invocation
     */
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        LoginUserVo user = ShiroUtil.getUser();
        log.info("user...{}", user);
        RpcContext.getContext().setAttachment("user", user);
        //todo 其他相关处理
        return invoker.invoke(invocation);
    }
}
